package com.zhihao.takeaway.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhihao.takeaway.common.utils.EasyUITable;
import com.zhihao.takeaway.entity.ShoppingCart;
import com.zhihao.takeaway.entity.ShoppingCartMarketerVo;
import com.zhihao.takeaway.mapper.ShoppingCartMapper;
import com.zhihao.takeaway.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart>
    implements ShoppingCartService {
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public EasyUITable getShoppingCartData(String UserId) {
        List<ShoppingCartMarketerVo> list = shoppingCartMapper.selectShoppingCartMarketer(UserId);
        Integer total = list.size();
        return new EasyUITable(total,list);
    }

    @Override
    public Integer insert(ShoppingCart shoppingCart) {
        Integer num = shoppingCartMapper.insert(shoppingCart);
        return num;
    }

    @Override
    public Integer cancel(String id) {
        Integer num = shoppingCartMapper.deleteById(id);
        return num;
    }
}
